function reverse(motor)
  speed = speedReading(motor)
  resetRotationCount(motor)
  forward(motor, -speed)
end

function lookFor(finder, distance)
  reverse(A)
  forward(B, -speedReading(A))
  repeat until finder() or abs(rotationCounts(A)) > distance
end

function search(finder) 
  distance = 10
  repeat
    lookFor(finder, distance)
    distance = distance * 2
  until finder()
end

function explore(finder)
  repeat
    if finder() then
      forward(A, 70)
      forward(B, 70)
    else 
      search(finder)
    end
  until isPressed(ESCAPE)
  stop(A)
  stop(B)
end





